package com.motu.vertx.module.utility.webhandler;
//
//import java.util.Iterator;
//import java.util.Map.Entry;

import com.motu.vertx.module.utility.webtool.BaseWebHandler;
import com.motu.vertx.module.utility.webtool.SearchCondition;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.client.WebClient;
import io.vertx.sqlclient.Pool;

import java.util.ArrayList;
import java.util.List;

public class ParamHandler extends BaseWebHandler{
	public static final String tableNameServer = "params";
	public static final String tableNameClient = "params_client";
	private static Pool jdbcClientServer = null;

	public static void init(Pool jdbcServer){
		jdbcClientServer = jdbcServer;
	}
	public static void client_list(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){
		List<SearchCondition> scList = new ArrayList<SearchCondition>();
		scList.add(new SearchCondition("key", "like", new String[]{"name","des"}, null));
		searchFromTable(routingContext, jdbcClientServer, json, tableNameClient, scList);
	}
	public static void client_add(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){
		addToTable(routingContext,jdbcClientServer, tableNameClient,null);
	}
	public static void client_update(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){
		updateToTable(routingContext,jdbcClientServer, tableNameClient,null);
	}
	public static void client_getone(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){
		getFromTable(routingContext,jdbcClientServer, tableNameClient);
	}
	public static void client_delete(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){
		deleteFromTable(routingContext,jdbcClientServer, tableNameClient);
	}

	public static void server_list(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){
		List<SearchCondition> scList = new ArrayList<SearchCondition>();
		scList.add(new SearchCondition("key", "like", new String[]{"name","des"}, null));
		searchFromTable(routingContext, jdbcClientServer, json, tableNameServer, scList);
	}
	public static void server_add(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){
		addToTable(routingContext,jdbcClientServer, tableNameServer,null);
	}
	public static void server_update(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){

		updateToTable(routingContext,jdbcClientServer, tableNameServer,null);
	}
	public static void server_getone(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){
		getFromTable(routingContext,jdbcClientServer, tableNameServer);
	}
	public static void server_delete(RoutingContext routingContext,JsonObject json,String adminName,WebClient client){
		deleteFromTable(routingContext,jdbcClientServer, tableNameServer);
	}

}
